<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itcast" uri="http://itcast.cn/common/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>失物招领</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Modern Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
 <!-- Bootstrap Core CSS -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/bootstrap.css">
<!-- Custom CSS -->
<link href="${pageContext.request.contextPath }/css/style1.css" rel='stylesheet' type='text/css' />
<link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css"> 
<!-- jQuery -->
<script src="${pageContext.request.contextPath }/js/jquery-1.11.0.js"></script>
<script src="${pageContext.request.contextPath }/js/jquery-form.js"></script>
<!--kindeditor的js  -->
<script charset="utf-8" src="${pageContext.request.contextPath }/js/kindeditor/kindeditor-all-min.js" type="text/javascript"></script>
<script charset="utf-8" src="${pageContext.request.contextPath }/js/kindeditor/lang/zh-CN.js" type="text/javascript"></script>
<!---//webfonts--->  
<!-- Bootstrap Core JavaScript -->
<script src="${pageContext.request.contextPath }/js/bootstrap.js"></script>

<script type="text/javascript">  
			var editor;
			KindEditor.ready(function(K) {
			  editor = K.create('textarea[name="lostdesccc"]', {
				  /* items:["undo","redo","|","image","|","preview","|","print","|","cut","copy","paste","plainpaste","wordpaste","|","justifyleft","justifyright","justifyfull","|","insertorderedlist"], */
				  	items: ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|', 'emoticons', 'image', 'link','|','preview'],
				  afterBlur:function(){this.sync();},
			       resizeType: 1,
			        <%-- uploadJson : '+<%=basePath%>+'AdminNews/uploadvvv',// 上传图片接口  项目名（此处项目名是wenjiqiwu）+上传图片的路径
	                filePostName: 'imgFile',// name属性默认值  --%>
			       allowPreviewEmoticons: false
			    });
			    
			});
</script>
<script type="text/javascript">  
			var editorr;
			KindEditor.ready(function(K) {
			  editorr = K.create('textarea[name="lostdesccccc"]', {
				  /* items:["undo","redo","|","image","|","preview","|","print","|","cut","copy","paste","plainpaste","wordpaste","|","justifyleft","justifyright","justifyfull","|","insertorderedlist"], */
				  	items: ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|', 'emoticons', 'image', 'link','|','preview'],
				  afterBlur:function(){this.sync();},
			       resizeType: 1,
			        <%-- uploadJson : '+<%=basePath%>+'AdminNews/uploadvvv',// 上传图片接口  项目名（此处项目名是wenjiqiwu）+上传图片的路径
	                filePostName: 'imgFile',// name属性默认值  --%>
			       allowPreviewEmoticons: false
			    });
			    
			});
</script>

    <script>
    	 /*全选或全不选*/
			//1.页面加载
			$(function(){
				//2.获取下面的复选框并将其选中状态设置跟编码的前端复选框保持一致
				$("#select").click(function(){
					 //atrr方法与JQ的版本有关，在1.8.3以下有关
					//$("tbody input[class='selectOne']").attr("checked",this.checked);
					$("tbody input[class='selectOne']").prop("checked",this.checked);
					
				});
			});
			
			/*全选删除*/
			function jjj(){
				var pList = "";
	            $("[name='all']").each(function () {
	                if ($(this).is(':checked')) {
	                    pList += $(this).val() + ",";
	                }
	            });
	            //去除最后的，
	           pList=pList.substr(0,pList.length-1);
	           var ids = pList;
	           if(pList==""){
	           	alert("请选择");
	           }else{
	           	var yes = confirm("您确定要删除所选吗?");
	           	if(yes){
	           		$.post(
							"<%=basePath%>adminlost/deletelostttt.html",
							{"ids":ids},
							function (data) {
								alert("删除成功!");
								location.href="<%=basePath%>adminLost/Lostlist.html";
							}
						);
	           	}
	           }

			}
			
			/* 单个删除 */
			function deletelost(id) {
				var y = confirm("您确定要删除吗?");
				if(y){
					$.post(
						"<%=basePath%>adminlost/deletelost.html",
						{"id":id},
						function (data) {
							alert("删除成功!");
							location.href="<%=basePath%>adminLost/Lostlist.html";
						}
					);
				}
			}
			
		</script>

</head>
<body>
<div id="wrapper">
     <!-- Navigation -->
        <jsp:include page="/WEB-INF/jsp/admin/common.jsp"></jsp:include>
        
        
        <div id="page-wrapper">
           <div class="row" style="background-color: wheat;">
           
              <div class="col-lg-8 navbar-left" style="padding-top: 15px;margin-left:10px;">
               <form class="form-inline" id="" action="${pageContext.request.contextPath }/adminLost/Lostlist.html" method="post">
               	     <!-- <div class="form-group">
					    <label for="exampleInputName2">姓名:</label>
					    <input type="text" class="form-control" id="exampleInputName2" placeholder="动物编号...">
					  </div>-->
					 <div class="form-group">
					    <label for="sexx">性别:</label>
					    <select id="sexx" name="sexx">
									<option value="">--请选择--</option>
									<option value="1" <c:if test="${sexx==1 }">selected</c:if>>男</option>
									<option value="2" <c:if test="${sexx==2 }">selected</c:if>>女</option>
								</select>
					  </div>
					  
					  <div class="form-group">
					    <label for="adresss">丢失地点：</label>
					    <input type="text" class="form-control" id="adresss" name="adresss" value="${adresss }" placeholder="地点...">
					  </div>
					  
					  <div class="form-group">
					    <label for="datee">丢失时间：</label>
					    <input type="date" class="form-control" id="datee" name="datee" value="${datee }">
					  </div>
					  
					   
					     
					  <button type="submit" class="btn btn-default">搜索</button>
					</form>
             </div>
              <div class="col-lg-2 navbar-right" style="padding-top: 5px;">
									
								<button class="btn btn-info btn-sm glyphicon glyphicon-plus" data-toggle="modal" data-target="#myModal2">
								添加
								</button>
								
					</div>
           </div>
           
        <div class="row">
        <div class="col-md-12">  
  	       <h3>失物招领</h3>
  	        <div class="bs-example4" data-example-id="contextual-table">
              <table class="table table-hover">
	             <caption><input type="checkbox" id="select">
	             	<a href="#" class="btn btn-danger btn-sm" onclick="jjj()">
									<span class="glyphicon glyphicon-trash"></span> 批量删除
								</a>
	             </input>
	             </caption>
					<thead>
						<tr>
							<th>序号</th>
							<th>姓名</th>
							<th>图片</th>
							<th>性别</th>
							<th>颜色</th>
							<th>丢失地点</th>
							<th>丢失时间</th>
							<th>失主</th>
							<th>联系方式</th>
							<th>是否发布</th>
							<th>操作</th>
							
						</tr>
					</thead>
						<tbody>
						<c:forEach var="row" items="${page.rows }" varStatus="vs">
							<tr>
								<td><input type="checkbox" class="selectOne" value="${row.id }" name="all"/><span id="" style="padding-left: 5px;">${vs.count }</span></td>
								<td>${row.lostname }</td>
								<td>
									 <img src="${row.lostimage }" class="img-thumbnail" alt="Cinque Terre" width="30px" height="30px">
								</td>
								<td>${row.lostsex==1?"男":"女" }</td>
								<td>${row.lostcolor}</td>
								<td>${row.lostaddress }</td>
								<td>${row.losttime }</td>
								<td>${row.lostman }</td>
								<td>${row.losttel }</td>
								<td>${row.loststatus==1?"是":"否" }</td>
								<td>
								<!--编辑-->
								<a href="#" onclick="editlost(${row.id})">
									<!--<span class="glyphicon glyphicon-edit"></span>-->
									<button class="btn btn-info btn-sm glyphicon glyphicon-edit" data-toggle="modal" data-target="#myModal">
											编辑
											</button>
										
									
											
								</a>
								&nbsp;&nbsp;
								<!--删除-->							
								<a href="#" class="btn btn-danger btn-sm" onclick="deletelost(${row.id})">
									<span class="glyphicon glyphicon-trash"></span> 删除
								</a>
								
							</td>	
							</tr>
							</c:forEach>
					</tbody>
				</table>
				<div class="col-md-12 text-right">
				<span>共<font style="color: red;">${total}</font>条数据</span><itcast:page url="${pageContext.request.contextPath }/adminLost/Lostlist.html" />
             		</div>
             </div>
            </div>
            </div>
            
            
      </div>
      <!-- /#page-wrapper -->
   </div>
   
   <!--添加弹出层-->
   <div class="update_modal">
		
		<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModal2Label" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content" style="background-color:#A6A6A6;">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
				</button>
				
				
				
						<h4 class="modal-title" id="myModal2Label">
					添加
				</h4>
					
					<form class="form-horizontal" role="form" action="" id="lostsaveform" method="post" enctype="multipart/form-data">
	
						<div class="form-group">
							<label for="lostname1" class="col-sm-2 control-label">姓名</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostname1" name="lostname">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostimage11" class="col-sm-2 control-label">图片</label>
							<div class="col-sm-4">
								<img id="lostimage11" name="lostimage" src="${pageContext.request.contextPath }/img/1.jpg" width="50px" height="50px" class="hidden"/>
    							<input type="hidden" name="lostimage" id="picc" value="">
								<input type="file" name="imgs1" id="imgs1" onchange="imgfun1()">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostkind" class="col-sm-2 control-label">品种</label>
							<div class="col-sm-4">
								<select id="lostkind1" name="lostkind">
								    <option value="">--请选择--</option>
									<option value="1">狗狗</option>
									<option value="2">猫猫</option>
									<option value="3">其他</option>
								</select>
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostsex1" class="col-sm-2 control-label">性别</label>
							<div class="col-sm-4">
								<select id="lostsex1" name="lostsex">
								    <option value="">--请选择--</option>
									<option value="1">男</option>
									<option value="2">女</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="lostcolor1" class="col-sm-2 control-label">颜色</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostcolor1" name="lostcolor">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostaddress1" class="col-sm-2 control-label">丢失地点</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostaddress1" name="lostaddress">
							</div>
						</div>
						
						<div class="form-group">
							<label for="losttime1" class="col-sm-2 control-label">丢失时间</label>
							<div class="col-sm-4">
								<input type="date" class="form-control" id="losttime1" name="losttime">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostdesc1" class="col-sm-2 control-label">描述</label>
							<div class="col-sm-8">
								<!-- <textarea id="lostdesc1" name="lostdesc" style="width: 350px; height: 250px;"></textarea> -->
								<textarea id="lsot_id" name="lostdesccc" style="width:100%;height:250px;border: 0 none;visibility:hidden;"></textarea>
            								<textarea rows="" cols="" name="lostdesc" id="lostdesc1" style="width:80%;height:250px;display:none;"></textarea>
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostman1" class="col-sm-2 control-label">失主</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostman1" name="lostman">
							</div>
						</div>
						
						<div class="form-group">
							<label for="losttel1" class="col-sm-2 control-label">联系方式</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="losttel1" name="losttel">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostemail1" class="col-sm-2 control-label">邮箱</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostemail1" name="lostemail">
							</div>
						</div>

					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
						<button type="button" class="btn btn-primary" onclick="addlost()">
					添加
				</button>
				
				</form>
				
					</div>
				</div>
				
			</div>
			
		</div>
		
		</div>
		
		<!--编辑弹出层-->
		<div class="update_modal">
		
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content" style="background-color:#A6A6A6;">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
				</button>

						<h4 class="modal-title" id="myModalLabel">
					编辑
				</h4>
					
					<form class="form-horizontal" role="form" id="losteditform" method="post" enctype="multipart/form-data">
						<input type="hidden" id="id" name="id" value=""/>
	
						<div class="form-group">
							<label for="lostname" class="col-sm-2 control-label">姓名</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostname" name="lostname">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostimage" class="col-sm-2 control-label">图片</label>
							<div class="col-sm-4">
								<img id="lostimage" name="lostimage1" src="../img/1.jpg" width="50px" height="50px"/>
    							<input type="hidden" name="lostimage" id="piccc" value="">
								<input type="file" name="imgsss" id="imgsss" onchange="imgfunnn()">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostkind" class="col-sm-2 control-label">品种</label>
							<div class="col-sm-4">
								<select id="lostkind" name="lostkind">
								    <option value="">--请选择--</option>
									<option value="1">狗狗</option>
									<option value="2">猫猫</option>
									<option value="3">其他</option>
								</select>
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostsex" class="col-sm-2 control-label">性别</label>
							<div class="col-sm-4">
								<select id="lostsex" name="lostsex">
								<option value="1">男</option>
								<option value="2">女</option>
								</select>
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostcolor" class="col-sm-2 control-label">颜色</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostcolor" name="lostcolor">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostaddress" class="col-sm-2 control-label">丢失地点</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostaddress" name="lostaddress">
							</div>
						</div>
						
						<div class="form-group">
							<label for="losttime" class="col-sm-2 control-label">丢失时间</label>
							<div class="col-sm-4">
								<input type="date" class="form-control" id="losttime" name="losttime">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostdesc" class="col-sm-2 control-label">描述</label>
							<div class="col-sm-8">
								<!-- <textarea id="lostdesc" name="lostdesc" style="width: 350px; height: 250px;"></textarea> -->
								<textarea id="editlost_id" name="lostdesccccc" style="width:100%;height:250px;border: 0 none;visibility:hidden;"></textarea>
            								<textarea rows="" cols="" name="lostdesc" id="lostdesc" style="width:80%;height:250px;display:none;"></textarea>
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostman" class="col-sm-2 control-label">失主</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostman" name="lostman">
							</div>
						</div>
						
						<div class="form-group">
							<label for="losttel" class="col-sm-2 control-label">联系方式</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="losttel" name="losttel">
							</div>
						</div>
						
						<div class="form-group">
							<label for="lostemail" class="col-sm-2 control-label">邮箱</label>
							<div class="col-sm-4">
								<input type="text" class="form-control" id="lostemail" name="lostemail">
							</div>
						</div>
						<div class="form-group">
							<label for="loststatus" class="col-sm-2 control-label">是否发布</label>
							<div class="col-sm-4">
								<select id="loststatus" name="loststatus">
								<option value="1">是</option>
								<option value="2">否</option>
								</select>
							</div>
						</div>
						
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
						<button type="button" class="btn btn-primary" onclick="editlost1()">
					确定
				</button>
				
				</form>
				
					</div>
				</div>
				
			</div>
			
		</div>
		
		</div>
		
    <!-- /#wrapper -->
<!-- Nav CSS -->
<link href="${pageContext.request.contextPath }/css/custom.css" rel="stylesheet">
<!-- Metis Menu Plugin JavaScript -->
<script src="${pageContext.request.contextPath }/js/metisMenu.min.js"></script>
<script src="${pageContext.request.contextPath }/js/custom.js"></script>
<script type="text/javascript">
/* 信息回显 */
	function editlost(id) {
		$.post(
		"<%=basePath%>adminLost/findlost.html",
		{"id":id},
		function (data) {
			KindEditor.html('#editlost_id',data.lostdesc);//富文本框信息
			$("#id").val(data.id);
			$("#lostname").val(data.lostname);
			$("#lostimage").attr('src',data.lostimage);
			$("#piccc").val(data.lostimage);
			$("#lostkind").val(data.lostkind);
			$("#lostsex").val(data.lostsex);
			$("#lostcolor").val(data.lostcolor);
			$("#lostaddress").val(data.lostaddress);
			$("#losttime").val(data.losttime);
			/* $("#lostdesc").val(data.lostdesc); */
			$("#lostman").val(data.lostman);
			$("#losttel").val(data.losttel);
			$("#lostemail").val(data.lostemail);
			$("#loststatus").val(data.loststatus);
		},
		"json"
		);
	}
	/* 编辑页面图片上传 */
	function imgfunnn(){
	var obj = {
			url:"<%=basePath%>adminlost/uploadimage.html",
			dataType:"json",
			type:"post",
			success: function (result) {
				var objs;
				/* if((typeof result == 'object') && result.constructor == Object){
					objs = result;
				}else{
					objs = eval("("+result+")");
				} */
				$("#lostimage").attr("width","220px");
				$("#lostimage").attr("height","260px");
				$("#lostimage").attr("src",result);
				$("#piccc").val(result);
				/* $("#pimage1").removeClass("hidden"); */
			}
	};
	$("#losteditform").ajaxSubmit(obj);
}
	
	/*添加图片上传*/
	function imgfun1(){
		
		var obj = {
				url:"<%=basePath%>adminLost/uploadaddpic.html",
				dataType:"json",
				type:"post",
				success: function (result) {
					var objs;
					/* if((typeof result == 'object') && result.constructor == Object){
						objs = result;
					}else{
						objs = eval("("+result+")");
					} */
					$("#lostimage11").attr("width","220px");
					$("#lostimage11").attr("height","260px");
					$("#lostimage11").attr("src",result);
					$("#picc").val(result);
					$("#lostimage11").removeClass("hidden");
				}
		};			
		$("#lostsaveform").ajaxSubmit(obj);

	}
	
	/* 修改信息 */
	function editlost1() {
		$("#lostdesc").val($("#editlost_id").val());//信息同步
		$.post(
			"<%=basePath%>adminLost/editLost.html",
			$("#losteditform").serialize(),
			function (data) {
				alert("修改成功!");
				location.href="<%=basePath%>adminLost/Lostlist.html";
			}
		);
	}
	/* 添加 */
	function addlost() {
		$("#lostdesc1").val($("#lsot_id").val());//信息同步
		$.post(
			"<%=basePath%>adminLost/addlost.html",
			$("#lostsaveform").serialize(),
			function (data) {
				alert("添加成功!");
				location.href="<%=basePath%>adminLost/Lostlist.html";
			}
		);
	}
</script>
</body>
</html>